If you still have time, let's cover one more concept: conditionals.
A conditional is basically the computational equivalent of an "if - then" statement. For instance, if there's a chair beneath me, then I can take a seat. Conditionals are very powerful in programming because they allow us to perform different actions based on some condition.
Before, our amazing-turtle-saving-maze-program only applied to a single map at a time because we were just analyzing the situation ourselves and giving our turtle buddy explicit directions. What if our turtle buddy could do that sort of analysis by itself? Could we write an program that could solve any map?
Below you'll see our familiar turtle maze, complete with a Programming Canvas to the right with some additional blocks. The additional blocks are:
if patch-ahead: this block is a conditional that allows your turtle to check for one of four conditions. Is this patch ahead the goal? lava? safe? or an edge? This block will execute commands inside of it only if the condition is met.
maybe: this is a different type of conditional that depends on random chance. Your turtle will randomly choose to follow the commands inside of this block according to the probability you select.
randomly pick: this is yet another conditional that you might think of as an if-else statement. Your turtle will basically flip a coin. If heads, it will do the first thing. Otherwise, it will do the second thing.
Like our drawing turtle, your turtle will continuously run "to move" function you provide it until it meets an untimely doom or reaches the safety of the violet patch..
Using the provided blocks, try and come up with a to move program that can solve ANY of the mazes you throw at it. If your program successfully solves one puzzle, hit RESET and then run your program again.